package utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

public class DataSourceUtils {

    private static DataSource ds;

    static {
        try {
            InputStream is = DataSourceUtils.class.getClassLoader().getResourceAsStream("druid.properties");
            Properties pro = new Properties();
            pro.load(is);

            DataSource dataSource = DruidDataSourceFactory.createDataSource(pro);

            ds = dataSource;
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static DataSource getDs(){
        return ds;
    }
}
